<#assign ctx=springMacroRequestContext.contextPath />
<#include "/macro/publicMacro.ftl">
<#import "/macro/pagination.ftl" as Pagination>
<#import "/macro/FormItem.ftl" as Form>

<@header title="租户编辑">
    <link href="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.min.css" rel="stylesheet">
</@header>

<@body>
<h2 class="module-title">租户编辑</h2>

<div class="alert alert-primary" role="alert">
    <button class="btn btn-info" onclick="javascript: history.back(-1);return false;" >返回</button>
</div>

<form class="form-horizontal" id="tenantForm" action="${ctx}/tenant/save" method="post">
    <input type="hidden" name="id" value="${tenant.id}"/>
    <@Form.FormItem name="name" label="租户名称">
        <input type="text" class="form-control" name="name" id="name" aria-describedby="租户名称" value="${tenant.name}">
    </@Form.FormItem>
    <@Form.FormItem name="description" label="描述">
        <input type="text" class="form-control" name="description" id="description" aria-describedby="描述" value="${tenant.description}">
    </@Form.FormItem>
    <@Form.FormItem name="privateKey" label="公钥">
        <input type="text" class="form-control" name="privateKey" id="privateKey" aria-describedby="公钥" value="${tenant.privateKey}">
    </@Form.FormItem>
    <@Form.FormItem name="publicKey" label="私钥">
        <input type="text" class="form-control" name="publicKey" id="publicKey" aria-describedby="私钥" value="${tenant.publicKey}">
    </@Form.FormItem>
    <@Form.FormItem name="privateKey2" label="">
        <input type="text" class="form-control" name="privateKey2" id="privateKey2" aria-describedby="" value="${tenant.privateKey2}">
    </@Form.FormItem>
    <@Form.FormItem name="publicKey2" label="">
        <input type="text" class="form-control" name="publicKey2" id="publicKey2" aria-describedby="" value="${tenant.publicKey2}">
    </@Form.FormItem>
    <@Form.FormItem name="endDate" label="期限">
        <div class='input-group date' id='endDate1'>
            <input type="text" class="form-control" name="endDate" id="endDate" aria-describedby="期限" value="${(tenant.endDate?string('yyyy-MM-dd hh:mm:ss'))!}">
            <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
            </span>
        </div>
    </@Form.FormItem>
    <@Form.FormItem name="enable" label="是否可用">
        <input type="text" class="form-control" name="enable" id="enable" aria-describedby="是否可用" value="${tenant.enable}">
    </@Form.FormItem>
    <@Form.FormItem name="createTime" label="创建时间">
        <div class='input-group date' id='createTime1'>
            <input type="text" class="form-control" name="createTime" id="createTime" aria-describedby="创建时间" value="${(tenant.createTime?string('yyyy-MM-dd hh:mm:ss'))!}">
            <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
            </span>
        </div>
    </@Form.FormItem>
    <@Form.FormItem name="updateTime" label="更新时间">
        <div class='input-group date' id='updateTime1'>
            <input type="text" class="form-control" name="updateTime" id="updateTime" aria-describedby="更新时间" value="${(tenant.updateTime?string('yyyy-MM-dd hh:mm:ss'))!}">
            <span class="input-group-addon">
                <span class="glyphicon glyphicon-calendar"></span>
            </span>
        </div>
    </@Form.FormItem>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-primary">提交</button>
        </div>
    </div>
</form>
</@body>

<@footer>
    <script src="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.full.min.js"></script>
    <script src="${ctx}/resource/common/js/jquery.validate.min.js"></script>

    <script type="text/javascript">
        $(function () {
            $('#endDate').datetimepicker({
                format:'Y-m-d H:i:s',
                lang:'zh'});
            $('#createTime').datetimepicker({
                format:'Y-m-d H:i:s',
                lang:'zh'});
            $('#updateTime').datetimepicker({
                format:'Y-m-d H:i:s',
                lang:'zh'});
        });

        $().ready(function() {
            $("#tenantForm").validate({
                rules: {
                    id: {
                        required: true,
                        digits: true
                    },
                    name: "required" ,
                   description: {
                      maxlength: 1,024
                   },
                    privateKey: "required" ,
                    publicKey: "required" ,
                   privateKey2: {
                      maxlength: 2,048
                   },
                   publicKey2: {
                      maxlength: 2,048
                   },
                   endDate: {
                      maxlength: 10
                   },
                    enable: {
                        required: true,
                        digits: true
                    },
                    createTime: {
                        required: true,
                        date: true
                    },
                    updateTime: {
                        required: true,
                        date: true
                    }
                }
            });
        });
    </script>
</@footer>